﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using yunbo.Model.PPM;
using yunbo.Model.PPMS;
using yunbo.Repositorys.PPMRepositorys;
using yunbo.Repositorys.PPMSRepositorys;

namespace yunbo.Controllers.PPMControllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class Mes_gdrwController : ControllerBase
    {
        Mes_gdrwRepository Mes_gdrwRepository = new Mes_gdrwRepository();


        [HttpGet("GetMes_gdrw")]
        public IActionResult GetMes_gdrw()
        {
            List<Mes_gdrw> quans = Mes_gdrwRepository.GetMes_gdrw();
            return Ok(quans);
        }
        [HttpPost("AddMes_gdrw")]
        public IActionResult AddMes_gdrw(ADDgdrw scgd)
        {
            var quans = Mes_gdrwRepository.AddMes_gdrw(scgd);
            return Ok(quans);
        }
        [HttpPut("Updatesj")]
        public IActionResult Updatesj(string gdrw_code,int i, int state, int update_by)
        {
            int quans;
            if (i == 0) {
                quans = Mes_gdrwRepository.Updatekgsj(gdrw_code,state,update_by);
            }
            else
            {
                quans = Mes_gdrwRepository.Updatewgsj(gdrw_code, state, update_by);
            }
            return Ok(quans);
        }
        [HttpPut("UpdateStatus")]
        public IActionResult UpdateStatus(string gdrw_code, int state, int update_by, string scjh_code)
        {
            int quans = Mes_gdrwRepository.UpdateStatus(gdrw_code, state, update_by, scjh_code);
            return Ok(quans);
        }
        [HttpPut("WanGong")]
        public IActionResult WanGong(string code, int shu)
        {
            int quans = Mes_gdrwRepository.WanGong(code,shu);
            return Ok(quans);
        }

    }
}
